unit _fmMain;

interface

uses
  ValueList,
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;

type
  TfmMain = class(TForm)
    ScrollBox: TScrollBox;
    imgDeskCam: TImage;
    OpenDialog: TOpenDialog;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
  public
  published
    procedure rp_BitmapOfDeskCamDecoderIsReady(AParams:TValueList);
  end;

var
  fmMain: TfmMain;

implementation

uses
  Core;

{$R *.dfm}

procedure TfmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  TCore.Obj.View.Remove(Self);

  TCore.Obj.Finalize;
end;

procedure TfmMain.FormCreate(Sender: TObject);
begin
  TCore.Obj.Initialize;

  if ParamCount = 0 then begin
    if OpenDialog.Execute then begin
      TCore.Obj.Open(OpenDialog.FileName);
    end else begin
      Application.Terminate;
    end;
  end else begin
    TCore.Obj.Open(ParamStr(1));
  end;

  TCore.Obj.View.Add(Self);
end;

procedure TfmMain.rp_BitmapOfDeskCamDecoderIsReady(AParams: TValueList);
begin
  if TCore.Obj.GetBitmap(imgDeskCam.Picture.Bitmap) then imgDeskCam.Repaint;
end;

end.
